#include "MeasurE616AlgSide1Datum.h"

MeasurE616AlgSide1Datum::MeasurE616AlgSide1Datum(int i):MeasurE616AlgBase(i)
{

}

void MeasurE616AlgSide1Datum::operator()(cv::Mat &srcImg, int id)
{
    //side1 图   SE11，SE12  paras616\side1\SE.xml(SE11,SE12 (setup4)分别对应第一行和第二行)
     //int GetLineContours(cv::Mat srcimg, const vector<int> paras, vector<cv::Point>& contours);

     std::vector<std::vector<cv::Point>> resptVec;
     std::vector<std::vector<cv::Rect>> rangVec2;
     for(auto i=41;i<43;i++)
     {
         std::vector<int> tparas;
         for(auto j=0;j< m_dataAllVec[i].m_edgeParam.cols;j++)
         {
             tparas.push_back(m_dataAllVec[i].m_edgeParam.at<int>(i-41,j));
         }
         std::vector<cv::Rect> rangVec;
         TemplateMatch(srcImg,m_dataAllVec[i],rangVec);
         rangVec2.push_back(rangVec);
         cv::Mat imgt=srcImg(rangVec[0]).clone();
//         imshow("test png", srcImg);
         std::vector<cv::Point> contours;
//         edgedetect obj;
         MeasurE616EdgeDetect obj;
         obj.GetLineContours(imgt,tparas,contours);
         ImageCoordinateTransformation(contours,rangVec);
         resptVec.push_back(contours);
     }
     vector<cv::Point2f> datum;
//     edgedetect obj;
     MeasurE616EdgeDetect obj;
     obj.GetSideDatum616(resptVec[0],resptVec[1],datum);
     datum.clear();

     datum={cv::Point2f((156+rangVec2[0][0].x),(161+rangVec2[0][0].y)),cv::Point2f((1432+rangVec2[1][0].x),(150+rangVec2[1][0].y)),cv::Point2f(-466+rangVec2[1][0].x,150+rangVec2[1][0].y)};
//     datum={cv::Point2f(1241,1680),cv::Point2f(3139,2452),cv::Point2f(1241,2452)};

     MeasurE616AlgBase::datumSideVec[id]=datum;
     MeasurE616AlgBase::flagsideVec[id] = true;
     (*MeasurE616AlgBase::cvarptrsideVec[id]).notify_all();
}
